import { IPSModelSortable } from '../../ipsmodel-sortable';
import { IPSAppDEDataExport } from '../../app/dataentity/ipsapp-dedata-export';
import { IPSDEDataExport } from './ipsdedata-export';
import { IPSDEDataExportGroup } from './ipsdedata-export-group';
import { IPSDEDataExportItem } from './ipsdedata-export-item';
import { IPSSysPFPlugin } from '../../res/ipssys-pfplugin';
import { IPSSysSFPlugin } from '../../res/ipssys-sfplugin';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDEDataExportImpl extends PSModelObjectImpl implements IPSDEDataExport, IPSAppDEDataExport, IPSModelSortable {
  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get extendMode(): 0 | 2 {
    return this.M.extendMode != null ? this.M.extendMode : 0;
  }

  get groupLevel(): number {
    return this.M.groupLevel != null ? this.M.groupLevel : 0;
  }

  get maxRowCount(): number {
    return this.M.maxRowCount;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  get orderValue(): number {
    return this.M.orderValue != null ? this.M.orderValue : 99999;
  }

  get pOTime(): number {
    return this.M.pOTime != null ? this.M.pOTime : -1;
  }

  protected psdedataexportgroups: IPSDEDataExportGroup[] | null = null;

  getPSDEDataExportGroups(): IPSDEDataExportGroup[] | null {
    if (this.psdedataexportgroups == null) {
      this.psdedataexportgroups = this.fillChildListModel(this.M.getPSDEDataExportGroups, 'dataentity.dataexport.IPSDEDataExportGroup') as IPSDEDataExportGroup[];
    }
    return this.psdedataexportgroups;
  }

  get psDEDataExportGroups(): IPSDEDataExportGroup[] | null {
    return this.getPSDEDataExportGroups();
  }

  findPSDEDataExportGroup(objKey: any): IPSDEDataExportGroup | null {
    return this.getPSModel5('dataentity.dataexport.IPSDEDataExportGroup', this.getPSDEDataExportGroups(), objKey) as IPSDEDataExportGroup;
  }

  protected psdedataexportitems: IPSDEDataExportItem[] | null = null;

  getPSDEDataExportItems(): IPSDEDataExportItem[] | null {
    if (this.psdedataexportitems == null) {
      this.psdedataexportitems = this.fillChildListModel(this.M.getPSDEDataExportItems, 'dataentity.dataexport.IPSDEDataExportItem') as IPSDEDataExportItem[];
    }
    return this.psdedataexportitems;
  }

  get psDEDataExportItems(): IPSDEDataExportItem[] | null {
    return this.getPSDEDataExportItems();
  }

  findPSDEDataExportItem(objKey: any): IPSDEDataExportItem | null {
    return this.getPSModel5('dataentity.dataexport.IPSDEDataExportItem', this.getPSDEDataExportItems(), objKey) as IPSDEDataExportItem;
  }

  protected pssyspfplugin: IPSSysPFPlugin | null = null;

  getPSSysPFPlugin(): IPSSysPFPlugin | null {
    if (this.pssyspfplugin != null) return this.pssyspfplugin;
    const value = this.M.getPSSysPFPlugin;
    if (value == null) {
      return null;
    }
    this.pssyspfplugin = this.getPSModel4('res.IPSSysPFPlugin', value, 'getPSSysPFPlugin') as IPSSysPFPlugin;
    return this.pssyspfplugin;
  }

  get psSysPFPlugin(): IPSSysPFPlugin | null {
    return this.getPSSysPFPlugin();
  }

  getPSSysPFPluginMust(): IPSSysPFPlugin {
    const value = this.getPSSysPFPlugin();
    if (value == null) {
      throw new Error('未指定前端扩展插件');
    }
    return value;
  }

  protected pssyssfplugin: IPSSysSFPlugin | null = null;

  getPSSysSFPlugin(): IPSSysSFPlugin | null {
    if (this.pssyssfplugin != null) return this.pssyssfplugin;
    const value = this.M.getPSSysSFPlugin;
    if (value == null) {
      return null;
    }
    this.pssyssfplugin = this.getPSModel4('res.IPSSysSFPlugin', value, 'getPSSysSFPlugin') as IPSSysSFPlugin;
    return this.pssyssfplugin;
  }

  get psSysSFPlugin(): IPSSysSFPlugin | null {
    return this.getPSSysSFPlugin();
  }

  getPSSysSFPluginMust(): IPSSysSFPlugin {
    const value = this.getPSSysSFPlugin();
    if (value == null) {
      throw new Error('未指定后台扩展插件');
    }
    return value;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get defaultMode(): boolean {
    return this.M.defaultMode != null ? this.M.defaultMode : false;
  }

  get enableBackend(): boolean {
    return this.M.enableBackend;
  }

  get enableFront(): boolean {
    return this.M.enableFront;
  }

  get cls(): string {
    return 'PSDEDataExportImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'IPSModelSortable' || cls == 'app.dataentity.IPSAppDEDataExport' || cls == 'app.dataentity.IPSAppDataEntityObject' || cls == 'dataentity.dataexport.IPSDEDataExport') return true;
    return super.instanceof(cls);
  }
}
